package com.example.oneSpringMVC.mapper;


import com.example.oneSpringMVC.entity.Role;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author xinTong
 * @since 2024-01-24
 */
public interface RoleMapper {

    /**
     * 角色分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Select("select * from rbac.role")
    Page<Role> list();

    /**
     * 总数
     * @return
     */
    @Select("select count(*) from rbac.role")
    int total();

    /**
     * 查询所有角色
     * @return
     */
    @Select("select * from rbac.role")
    List<Role> listAll();

    /**
     * 删除角色信息
     * @param roleId
     * @return
     */
    @Delete("delete from rbac.role where id = #{roleId}")
    void deleteByRoleId(Long roleId);

    /**
     * 删除角色信息
     * @param roleId
     * @return
     */
    @Delete("delete from rbac.role_permission where role_id = #{roleId}")
    void deleteByPermissionId(Long roleId);

    @Select("select * from rbac.role where id = #{roleId}")
    Role info(Long roleId);

    List<Role> query(Long employeeId);

    void updateByRoleId(Role role);

    void insert(Role role);
}
